package sgi.message;

import java.util.List;

import sgi.client.SGIUserAccountMenuController;
import sgi.details_new.ImageDetails;



/**sets query for searching image database*/
@SuppressWarnings("serial")
public class MessageSearch extends Message {
	
	private List<ImageDetails> images;
	public int img;
	public int searchMessageType;
	private String qHistory;
	
	/**Constructor. receives range of dates and location and sets query for searching
	 * also sets query for user account history update*/
	public MessageSearch(String dateFrom,String dateTo,String location)
	{
		super("select imageid,date,location,latitude,longitude from images where date between '" + dateFrom + "' and '" + dateTo + "' and location LIKE '%" + location + "%'");
		setqHistory("INSERT INTO `sgi`.`history` (`username`, `activity`) VALUES ('" + SGIUserAccountMenuController.getUser().getUsername() + "', 'Search-Dates: +"+dateFrom+"-"+dateTo+" Location: "+ location +"');");
	}
	/**same as previous constructor but with an unspecified location*/
	public MessageSearch(String dateFrom,String dateTo)
	{
		super("select imageid,date,location,latitude,longitude from images where date between '" + dateFrom + "' and '" + dateTo + "'");
		setqHistory("INSERT INTO `sgi`.`history_search` (`username`, `activity`) VALUES ('" + SGIUserAccountMenuController.getUser().getUsername() + "', 'Search-Dates: "+dateFrom+" -- "+dateTo+"');");
	}

	public List<ImageDetails> getImages() {
		return images;
	}

	public void setImages(List<ImageDetails> images) {
		this.images = images;
	}
	public void setSearchMessageType(int type) {
		this.searchMessageType = type;
	}
	public int getSearchMessageType() {
		return this.searchMessageType;
	}

	public String getqHistory() {
		return qHistory;
	}

	public void setqHistory(String qHistory) {
		this.qHistory = qHistory;
	}

}
